<template>
	<div>
		<el-table :data="tableData" border style="width: 100%" class="list">
			<el-table-column prop="id" label="房间id" width="70"></el-table-column>
			<el-table-column prop="type" label="房间类型" width="150"></el-table-column>
			<el-table-column prop="name" label="房间名字" width="120"></el-table-column>
			<el-table-column prop="price" label="价格" width="120"></el-table-column>
			<el-table-column prop="price_discount" label="折后价" width="100"></el-table-column>
			<el-table-column prop="stock" label="房间总数" width="80"></el-table-column>
			<el-table-column prop="status" label="状态(1.正常 0.停用)" width="150"></el-table-column>
			<el-table-column label="操作">
				<template slot-scope="scope">
					<el-button size="small" @click="$emit('change',scope.$index)">编辑</el-button>
					<el-button size="small" type="primary" @click="$emit('toPhotoList',scope.row)">图片</el-button>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
	export default {
		name: "RoomList",
		props: ["roomList"],
		computed: {
			tableData: function() {
				let arr = [];
				console.log(this.roomList, 789)
				this.roomList.forEach((item) => {
					console.log(item)
					let _item = { ...item
					};
					switch (_item.status) {
						case 1:
							_item.status = "正常";
							break;
						case 0:
							_item.status = "停用";
							break;

					}
					arr.push(_item);

				});
				return arr;
			}
		},
		methods: {
			handleEdit(index, row) {
				alert(index, row);
			}
		}
	};
</script>

<style lang="scss" scopted>
	.list {
		height: 70vh;
		overflow-y: scroll;

		&::before {
			display: none;
		}
	}
</style>
